﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WMS.BLL;
using WMS.Entity;

namespace WMS.App
{
    public partial class frmLogin : Form
    {
        private UserInfo user = new UserInfo();
        private UserInfoEntity entity { get; set; }
        private frmMain main = new frmMain();

        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            //this.txtUserName.Text = "admin";           
            entity = user.GetUserInfo(this.txtUserName.Text, this.txtPassword.Text);

            if (entity != null)
            {
                this.btnLogin.Enabled = false;
                main.Processing += Loading;
                main.CloseWindwsEvent += new EventHandler(CloseWindwsEvent);
                main.InitData();
            }
            else
            {
                MessageBox.Show("用户名或者密码错误！");
            }
        }

        void CloseWindwsEvent(object sender, EventArgs e)
        {
            this.Dispose();
        }

        void Loading(int value)
        {
            this.progressBarLoading.Value = value;
            if (value == 100)
            {
                main.userInfo = entity;
                main.Show();
                this.Hide();
            }
        }
    }
}
